<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>Insert title here</title>
		<link rel="stylesheet" href="./layui/css/layui.css">
		<script src="./layui/layui.js"></script>
		<script type="text/javascript" src="js/global.js"></script>
	</head>

	<body>
		<div class="layui-form-item" style="margin-top: 20px" onsubmit="false">
			<div class="layui-form-item">
				<div class="layui-form-item">
					<label class="layui-form-label">用户名</label>
					<div class="layui-input-inline">
						<input class="layui-input" name="askerName" id="askerName" lay-verify="required" />
					</div>
					<label class="layui-form-label">签到时间</label>
					<div class="layui-input-inline">
						<input class="layui-input" name="beginTime" id="beginTime" placeholder="yyyy-MM-dd HH:mm:ss"
							lay-verify="required" />
					</div>
					<label class="layui-form-label" style="width: 1px;">~</label>
					<div class="layui-input-inline">
						<input class="layui-input" name="endTime" id="endTime" placeholder="yyyy-MM-dd HH:mm:ss"
							lay-verify="required" />
					</div>
				</div>
				<label class="layui-form-label">签到状态</label>
				<div class="layui-input-inline">
					<select class="layui-input" id="checkState" lay-verify="required">
						<option value="">---请选择---</option>
						<option value="已签到">已签到</option>
						<option value="已签退">已签退</option>
					</select>
				</div>
				<button class="layui-btn" id="serach" data-type="reload">搜索</button>
				<button class="layui-btn" id="chongzhi" data-type="reload"><i class="layui-icon layui-icon-refresh-1"></i></button>
			</div>
		</div>
		<table id="demo1" lay-filter="test"></table>
		<table id="demo" lay-filter="test"></table>
		<!--<script type="text/html" id="barDemo">
			<a class="layui-btn layui-btn-xs" lay-event="edit">修改权重</a>
		</script>-->
		<!-- 按钮 -->
		<!--<script type="text/html" id="isopens">
			{{# if(d.isopens == 1){ }}
			<input type="checkbox" name="isopens" lay-skin="switch" value="{{d.id}}" lay-text="是|否" lay-filter="zhuangtaiDemo" {{ d.isopens==1 ? 'checked' : '' }}> 
			{{# }else{ }}
			<input type="checkbox" name="isopens" lay-skin="switch" value="{{d.id}}" lay-text="是|否" lay-filter="zhuangtaiDemo" {{ d.isopens==1 ? 'checked' : '' }}> 
			{{# } }}
		</script>-->
		<script>
			layui.use(['table', 'form', 'laydate'], function() {
				var table = layui.table;
				var $ = layui.jquery; //引入jquery
				var form = layui.form;
				var laydate = layui.laydate;
				//解决跨域
				$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
					options.xhrFields = {
						withCredentials: true
					}
				})
				//第一个实例
				table.render({
					elem: '#demo'
						//	    ,toolbar : '#toolbarDemo'//开启头部栏工具
						,
					url: globalData.server + './asker/getAllAsker' //数据接口
						,
					page: true //开启分页
						,
					method: 'POST',
					id: 'idTest',
					cols: [
						[ //表头
							{
								field: 'askerId',
								title: 'ID',
								sort: true,
								fixed: 'left',
								align: 'center'
							}, {
								field: 'askerName',
								title: '用户名',
								align: 'center'
							}, {
								field: 'checkState',
								title: '签到状态',
								align: 'center'
							}, {
								field: 'checkInTime',
								title: '签到时间',
								align: 'center'
							}, {
								field: 'checkOutTime',
								title: '签退时间',
								align: 'center'
							}
							/*, {
															field: 'weight',
															title: '权重',
															width: 100,
															align: 'center'
														}*/
							//	      ,{field: 'bakConten', title: '内容', width:180,align : 'center'}
//							, {
//								field: 'right',
//								title: '操作',
//								toolbar: '#barDemo',
//								align: 'center',
//								width: 250
//							}
						]
					]
				});
				//常规用法
				laydate.render({
					elem: '#beginTime',
					type: 'datetime'
				});
				//日期时间范围
				//常规用法
				laydate.render({
					elem: '#endTime',
					type: 'datetime'
				});
				$('#serach').on('click', function() {
					var askerName = $("#askerName").val(); //上面搜索框的id
					var beginTime = $("#beginTime").val(); //上面搜索框的id
					var endTime = $("#endTime").val(); //上面搜索框的id
					var checkState = $("#checkState").val(); //上面搜索框的id
					table.reload('idTest', {
						where: { //请求参数
							'askerName': askerName,
							'beginTime': beginTime,
							'endTime': endTime,
							'checkState': checkState,
						}
					});
				});
				/* 重置文本框 */
				$('#chongzhi').on('click', function() {
					$(":input").val('');
					table.reload('idTest', {
						where: { //请求参数
							'name': name,
						}
					});
				});
				/*//监听工具条
				table.on('tool(test)', function(obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
					var data = obj.data; //获得当前行数据
					if(obj.event === 'edit') { //编辑
						layer.open({ //打开一个页面
							type: 2, //在当前页面之上以弹框的形式，展示编辑页面
							area: ['500px', '550px'], //页面宽高
							content: 'asker-edit.html', //页面所在位置
							title: '您正在编辑咨询师为' + obj.data.askerName + '的权重信息',
							success: function(layero, index) {
								var body = layer.getChildFrame('body', index);
								body.contents().find("#askerId").val(obj.data.askerId);
								body.contents().find("#weight").val(obj.data.weight);
							},
							end: function() {
								window.location.reload(); //当窗口关闭后刷新页面
							}
						});
					}
				});*/

			});
		</script>
		<!--<script>
			layui.use(['table', 'form'], function() {
				var table = layui.table;
				var $ = layui.jquery; //引入jquery
				var form = layui.form;
				//第一个实例
				table.render({
					elem: '#demo1',
					url: globalData.server + './openClose/getAll' //数据接口
						,
					method: 'POST',
					cols: [
						[{ //ON(允许系统自动分)/OFF(手动分
							field: 'isopens',
							title: '是否允许系统自动分配',
							toolbar: '#isopens',
							align: 'center'
						}]
					]

				});
				form.on('switch(zhuangtaiDemo)', function(obj) {
					var id = this.value;
					var name = this.name;
					var result = obj.elem.checked;
					console.log(result);
					var isopens = "";
					if(result) {
						isopens = 1; //打开 允许
					} else {
						isopens = 2; //2关闭e
					}
					$.post(globalData.server + './openClose/update', {
							"id": id,
							"isopens": isopens,
						},
						function(data) {
							if(data.count > 0) {
								layer.msg('修改成功', {
									icon: 1,
									time: 2000 //2秒关闭（如果不配置，默认是3秒）
								}, function() {
									//do something
								});
							}
						}, "json");
				});

			});
		</script>-->
	</body>

</html>
